#ifndef _MyPosCreator_H_
#define _MyPosCreator_H_

#include <map>
#include <string>

typedef void* (*CreateMyPos)();

class MyPosCreator
{
public:
    static MyPosCreator& GetInstance()
    {
        static MyPosCreator Instance;
        return Instance;
    }
    inline void RegistMyPos(std::string name, CreateMyPos gPSPos) {m_AvaiableMyPos[name] = gPSPos;}
    void* CreateNewMyPos(std::string);

    ~MyPosCreator();

private:
    MyPosCreator();

    std::string m_MyPosName;
    std::map<std::string, CreateMyPos> m_AvaiableMyPos;

};

#define REGISTPOSGEN(name)\
void* CREATE##name(){\
    name* fil = new name();\
    return (fil == nullptr) ? nullptr : fil;\
}\
class REGIST##name\
{\
public:\
    REGIST##name()\
    {\
        MyPosCreator::GetInstance().RegistMyPos(#name, CREATE##name);\
    }\
};\
REGIST##name regist##name;

#endif